﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PackTracker.Mobile.Negocio.RFID
{
    public class Tag
    {
        #region Propriedades
        protected string id;

        public string ID
        {
            get { return id; }
            set { id = value; }
        }

        protected DateTime discovered;

        public DateTime Discovered
        {
            get { return discovered; }
            set { discovered = value; }
        }

        protected DateTime last;

        public DateTime Last
        {
            get { return last; }
            set { last = value; }
        }

        protected int count;

        public int Count
        {
            get { return count; }
            set { count = value; }
        }

        protected int ant;

        public int Ant
        {
            get { return ant; }
            set { ant = value; }
        }

        protected int proto;

        public int Proto
        {
            get { return proto; }
            set { proto = value; }
        }
        #endregion

        public Tag(string id, DateTime discovered, DateTime last, int count, int ant, int proto)
        {
            if (id.Length != 29)
                throw new Exception("Invalid ID");

            this.id         = id;
            this.discovered = discovered;
            this.last       = last;
            this.count      = count;
            this.ant        = ant;
            this.proto      = proto;
        }

        public Tag(string registro)
        {
            this.id = registro.Substring(4,29);
            this.discovered = DateTime.Parse(registro.Substring(40, 19));
            this.last = DateTime.Parse(registro.Substring(66, 19));
            this.count = int.Parse(registro.Substring(93, 1));
            this.ant = int.Parse(registro.Substring(100, 1));
            this.proto = int.Parse(registro.Substring(109, 1));
        }

    }
}
